import torch
import torch.nn as nn

from medical_ner.models.classify_model.crf import log_sum_exp, CRFLayer
from medical_ner.utils.constants import TAG2ID


def t0():
    # x = torch.abs(torch.randn(5, 3)) * -10000.0
    x = torch.abs(torch.randn(5, 3))
    print(x)
    p = torch.softmax(x, dim=-1)  # softmax的概率值
    print(p)
    p = torch.log(p)  # log(pi)的损失值
    print(p)

    logz = log_sum_exp(x, keepdim=True)
    print(logz)
    print(x - logz)  # log(softmax(x))


def t1():
    """
    CRF相当于在Softmax的概率求解公式上进行了一个修正
    softmax交叉熵损失:
        zi = wx+b
        pi = softmax(zi)
        loss = - log(pi)
        loss = loss.sum()
        loss = loss/N
        NOTE: 损失计算过程中，选择的是实际类别对应的预测概率
    crf交叉熵损失：
        zi = wx+b
        si = zi + transition  # 修正后的置信度
        pi = softmax(si)
        loss = - log(pi)
        loss = loss.sum()
        loss = loss/N
        NOTE: 由于transition中有一些状态到状态之间的转移值是"负无穷大", 求解log(softmax)的时候会出现inf/溢出的问题,针对log(softmax)的求解方式更改为log_sum_exp
    :return:
    """
    crf = CRFLayer(TAG2ID)

    feats = torch.randn(5, 2, len(TAG2ID))  # 5个时刻，2个样本，以及对应的M个类别的置信度
    mask = torch.tensor([
        [1, 1],
        [1, 1],
        [1, 1],
        [0, 1],
        [0, 1]
    ], dtype=torch.float32)
    crf_labels = torch.tensor([
        [5, 0],
        [6, 2],
        [7, 3],
        [0, 4],
        [0, 0]
    ])
    forward_score = crf(feats, mask)
    gold_score = crf.score_sentence(feats, crf_labels, mask)
    loss = forward_score - gold_score  # -log(pi)
    loss = loss.mean()
    print(loss)

    output = crf.viterbi_decode(feats, mask)
    print(output)


def t2():
    crf = CRFLayer(TAG2ID)

    c0 = crf.transition.detach().numpy()

    c1 = torch.Tensor([
        [-1.1938e-01, 1.5610e-01, -1.0000e+04, -6.7548e-02, 2.0997e-01,
         2.2695e-01, -5.5058e-02, -3.5351e-01, 2.7338e-02, 1.5181e-01,
         -8.1342e-02, 9.5626e-02, -6.5535e-02, -1.5810e-02, 6.9750e-02,
         -2.6411e-01, -2.1117e-01, 4.0186e-02, -4.6564e-02, 2.2930e-02,
         -6.9971e-02, 3.0824e-02, 3.4426e-02, 1.9818e-01, 1.0857e-01,
         2.0696e-01, -2.4171e-01],
        [-1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04],
        [-1.1855e-01, 2.1503e-01, -1.0000e+04, -2.5087e-01, -2.6390e-01,
         1.9833e-02, 5.3308e-02, -4.8363e-03, -7.6665e-02, -1.2662e-01,
         1.4323e-01, -1.3326e-01, -2.0691e-01, -2.0230e-01, -1.8227e-01,
         -1.3648e-01, -1.5704e-02, 1.4045e-01, -3.6868e-01, -6.2985e-01,
         1.5011e-01, -3.1764e-01, -1.2644e-01, -2.0788e-01, -3.9955e-01,
         1.7303e-01, 1.5643e-02],
        [5.8579e-01, -2.4591e-01, -1.0000e+04, 2.3059e-02, 1.7964e-01,
         -2.0282e-01, -5.4282e-02, 3.1985e-02, -2.8480e-01, -1.2941e-01,
         1.3406e-02, -2.0129e-01, -2.1326e-02, -1.4211e-01, -2.6779e-01,
         -1.0860e-01, -9.9834e-02, -4.1058e-01, 1.6742e-02, -1.6007e-01,
         3.2146e-01, 2.6805e-01, 1.2936e-01, 2.4696e-01, -1.7041e-01,
         -4.5450e-01, 1.1879e-01],
        [-3.2008e-01, -4.5608e-01, -1.0000e+04, 5.4589e-01, -6.7684e-02,
         -2.7664e-01, -1.8045e-01, -1.2882e-01, -4.1509e-02, -2.7821e-01,
         -2.2232e-01, -1.0904e-01, -8.4691e-02, 7.8131e-03, -8.6924e-02,
         -4.3166e-01, -2.2403e-01, -9.6196e-02, -2.3012e-01, -2.6865e-01,
         -2.3571e-01, 1.6263e-01, -8.5409e-02, 9.7384e-02, -8.4700e-02,
         -1.6586e-02, 1.0368e-01],
        [2.7736e-01, -7.7748e-02, -1.0000e+04, -5.1763e-02, 3.9163e-01,
         4.8298e-02, -1.3696e-01, 1.6077e-02, -3.6698e-01, -1.7674e-02,
         7.2713e-02, 1.2010e-02, 1.9852e-01, -1.9613e-01, -3.1534e-02,
         -3.9517e-01, -7.9997e-02, -6.6439e-02, 4.1225e-03, 3.2301e-01,
         -2.1502e-01, -1.2654e-01, -2.3880e-01, -2.8968e-01, -5.7847e-02,
         1.2363e-01, -1.2918e-01],
        [3.1032e-01, -2.2850e-02, -1.0000e+04, -9.6605e-02, 1.4620e-01,
         -3.4789e-01, -2.7833e-01, -7.9151e-02, -1.5974e-01, 2.1645e-01,
         -8.5821e-02, -1.6217e-01, -1.8980e-01, -9.0281e-02, -8.9099e-02,
         -2.7259e-01, -1.2232e-01, -7.1480e-02, -2.3828e-01, -2.0023e-01,
         1.3776e-01, -3.6834e-01, -2.4737e-01, -3.5816e-02, -7.5346e-02,
         -3.1863e-02, -2.4669e-01],
        [4.4036e-02, -4.0656e-01, -1.0000e+04, 1.3024e-01, 2.3368e-02,
         -9.5689e-02, -1.5426e-03, -1.1662e-01, -4.8427e-02, -1.9577e-01,
         5.6186e-02, -1.0135e-01, 8.8641e-02, -1.5676e-01, -9.6210e-02,
         9.4900e-02, -3.1459e-01, -2.2760e-01, -2.5570e-01, 1.1293e-01,
         -8.3730e-02, 6.3602e-02, -2.0535e-01, -1.7448e-01, -1.4585e-02,
         -6.7978e-02, 1.0442e-01],
        [-4.7356e-02, -2.9979e-01, -1.0000e+04, -2.0604e-01, 3.0387e-02,
         -4.1627e-01, -1.8664e-01, 2.3951e-02, 1.6511e-01, 4.0951e-01,
         2.3115e-01, -4.3633e-01, -2.0726e-01, 1.2422e-02, -5.4869e-02,
         -3.9093e-02, -2.3548e-01, 4.3176e-03, -1.7285e-01, 5.9815e-02,
         2.3746e-01, 2.7439e-01, 1.2270e-01, 2.6691e-02, -1.6420e-02,
         -3.5208e-01, 1.2093e-01],
        [-4.7858e-01, -6.0938e-02, -1.0000e+04, -3.2893e-01, -2.5112e-01,
         -3.0089e-01, -1.5510e-01, -8.9591e-02, 1.3129e-01, -1.5010e-01,
         -2.6774e-01, -3.2964e-01, -7.0929e-02, 4.3941e-01, -5.1780e-02,
         -4.9600e-02, -2.5183e-01, -2.2445e-01, 9.8740e-02, -6.8273e-03,
         -5.4145e-03, 1.3399e-01, -2.1385e-01, -1.2085e-01, -9.3840e-02,
         3.2092e-02, 8.1439e-02],
        [1.4320e-02, -4.9213e-01, -1.0000e+04, 1.2359e-01, 1.9238e-01,
         -9.2559e-02, -3.0985e-01, -4.7180e-01, -1.8813e-01, -6.7420e-02,
         7.8528e-02, 8.4681e-02, -2.4334e-01, -4.0307e-01, -5.4731e-02,
         4.0900e-03, 8.8522e-03, -1.5285e-01, -8.5387e-02, -5.2086e-01,
         1.1732e-01, -8.9822e-02, -5.4110e-02, 4.3180e-02, 1.2221e-02,
         -1.7955e-01, -1.5875e-01],
        [1.0700e-01, -1.0351e-01, -1.0000e+04, -2.1524e-01, 7.5450e-02,
         1.6882e-01, 2.2180e-02, -2.1414e-01, -1.0521e-02, 1.0655e-01,
         -5.1525e-02, -2.4742e-01, -3.4736e-01, 1.1140e-01, -5.7618e-01,
         -9.2062e-02, -2.8747e-02, 1.1061e-01, -2.6622e-01, -2.8511e-01,
         3.1093e-02, -4.6297e-01, -1.4960e-01, -6.3175e-01, -6.1024e-01,
         3.9101e-02, 5.8154e-02],
        [-2.8655e-01, -6.8912e-01, -1.0000e+04, 1.6209e-01, -2.1855e-01,
         1.6905e-01, 5.2631e-02, -4.6967e-02, -3.0426e-01, -1.1529e-01,
         -1.1575e-01, 6.0451e-01, 2.6866e-01, -1.8394e-01, -6.8571e-02,
         -2.9180e-01, -1.9080e-01, -1.0233e-01, 1.2598e-01, 7.0588e-02,
         -1.0235e-01, 8.1569e-02, 3.4161e-02, -1.5768e-01, -3.4906e-01,
         7.4702e-02, 1.1603e-01],
        [-2.8412e-01, 7.3309e-02, -1.0000e+04, -1.7196e-01, -3.0594e-01,
         -2.4243e-02, -2.7569e-01, 1.5621e-01, -8.0483e-02, -2.8190e-02,
         -2.9201e-01, 1.5451e-01, 6.8046e-02, -1.0463e-01, -2.6022e-01,
         -2.6825e-01, 6.8548e-02, -2.4902e-01, -1.2664e-01, 2.9186e-02,
         1.9787e-01, 1.3576e-01, -2.4461e-01, -5.0851e-01, -1.0124e-01,
         -1.4496e-01, -2.7004e-01],
        [1.7454e-01, -4.2278e-01, -1.0000e+04, -1.0471e-01, 2.8554e-01,
         -1.0004e-01, -6.1380e-02, -4.2269e-01, -3.0008e-02, -8.7945e-02,
         -1.1053e-01, -1.0291e-01, -4.6190e-03, 2.3214e-02, -3.9648e-02,
         -1.2230e-01, -1.5668e-01, -2.0794e-01, -2.8197e-01, -4.6936e-01,
         -1.2629e-01, -9.4690e-02, -4.0703e-01, 6.9209e-02, -5.9984e-02,
         6.5540e-02, -3.0546e-02],
        [1.8020e-01, -2.3074e-02, -1.0000e+04, -1.3310e-01, -2.6363e-01,
         -5.5592e-02, -1.4860e-01, -3.2830e-01, 4.3198e-02, -2.1395e-01,
         -1.8072e-02, -1.0528e-01, -2.1843e-02, -2.8994e-01, -4.1659e-01,
         -5.1689e-02, -2.7098e-01, 5.2475e-02, -3.8437e-01, -8.5897e-02,
         -3.0260e-01, 1.8787e-02, -2.5465e-01, -1.5886e-01, -5.8428e-02,
         -4.3419e-01, 5.6730e-02],
        [3.3465e-01, -3.4660e-02, -1.0000e+04, -1.4522e-02, 6.2642e-02,
         -3.3127e-01, -3.2897e-01, -8.6880e-02, 1.9302e-01, 1.5045e-01,
         1.0229e-01, 2.7035e-03, 1.6169e-01, -1.8870e-01, -1.1599e-01,
         -1.2450e-01, -1.0520e-01, -1.5970e-01, -5.3070e-02, -3.7180e-01,
         1.5553e-03, 4.4160e-01, 3.3107e-01, -4.4136e-02, -2.2384e-01,
         -4.0268e-01, -1.7821e-01],
        [-2.6414e-01, -2.5748e-01, -1.0000e+04, -2.3665e-02, -7.2199e-02,
         3.4067e-02, 3.0056e-02, -1.8260e-01, -1.0450e-01, -1.2130e-01,
         -2.1827e-01, 2.0271e-01, 2.2006e-01, -3.1327e-01, 1.9846e-01,
         -2.2430e-02, -3.3070e-02, -2.7259e-01, -8.3783e-02, -2.6818e-01,
         -4.2412e-01, -3.1878e-01, -1.0438e-02, -2.3614e-01, -2.1543e-01,
         1.8998e-01, -1.2284e-01],
        [5.9142e-02, -9.0767e-02, -1.0000e+04, 2.1215e-03, -2.6100e-01,
         -1.1685e-01, -8.8027e-02, 9.6905e-02, -1.6050e-02, -1.3037e-01,
         3.2239e-02, -1.1592e-01, -1.1620e-01, 2.5140e-01, -2.7566e-01,
         -2.3443e-01, 2.5907e-01, -3.4864e-01, -2.0655e-01, -5.4238e-01,
         -2.6268e-02, -4.5198e-01, -3.2064e-02, 5.6363e-02, -5.1214e-01,
         -7.5963e-02, 8.8907e-02],
        [-5.1584e-02, -3.6412e-01, -1.0000e+04, 2.3725e-01, -1.5687e-01,
         -5.5946e-02, -4.8511e-01, -1.7652e-01, -2.9332e-01, -1.5318e-01,
         -5.0132e-02, 2.0893e-01, -2.2397e-01, 1.4925e-01, 2.5303e-01,
         -3.1459e-01, 1.1059e-01, -5.0316e-01, 2.1253e-02, -1.4187e-01,
         -4.6169e-01, -7.6073e-02, -1.4677e-01, -1.8824e-01, 9.1441e-02,
         -1.0776e-01, -2.8888e-01],
        [-2.8017e-01, 2.9855e-01, -1.0000e+04, -1.1592e-01, -1.2453e-02,
         1.9521e-01, 1.4802e-01, -1.7415e-01, -1.1128e-01, -2.9692e-01,
         -1.6384e-01, -2.7550e-02, -1.5249e-01, 6.8569e-01, -1.9000e-01,
         -1.4608e-01, -1.1886e-01, -1.2188e-01, -6.4012e-02, -1.9070e-01,
         6.1202e-02, -1.8224e-01, 1.9262e-01, -1.1180e-01, -2.3108e-01,
         -1.4732e-01, -6.7914e-02],
        [-2.0472e-01, -4.4846e-01, -1.0000e+04, -1.5189e-01, -1.8961e-01,
         -3.3161e-01, -1.0433e-01, 5.3121e-02, 7.7696e-02, 2.3443e-01,
         -2.2909e-01, -2.5532e-01, 9.7146e-02, -1.5210e-01, 7.4280e-02,
         -1.9308e-01, -1.9207e-02, -3.5801e-01, -5.3249e-01, -1.0614e-01,
         -4.4814e-01, -1.5868e-01, -1.2202e-01, -3.6788e-01, 5.9120e-02,
         -1.5992e-01, -3.3560e-01],
        [1.2479e-01, -9.7441e-02, -1.0000e+04, 1.1996e-01, -6.9314e-02,
         -9.4519e-03, 5.9291e-02, -2.2807e-01, -1.7631e-01, -1.7437e-01,
         -5.9716e-01, 1.9283e-03, 1.2068e-01, -3.3921e-01, -2.4802e-01,
         -1.7593e-01, -5.6714e-03, -2.0534e-01, -2.3454e-01, -3.9612e-01,
         -4.3970e-01, -6.2134e-02, -3.9447e-01, 1.0358e-02, 1.6636e-01,
         -3.0449e-01, -2.9868e-02],
        [1.0043e-01, 1.7247e-01, -1.0000e+04, -8.5335e-02, -2.1596e-01,
         -3.1215e-01, -1.3548e-01, -1.1065e-01, -4.3090e-01, -2.1770e-01,
         -4.0239e-01, -4.1535e-02, -1.5453e-01, -2.8219e-01, -3.2267e-01,
         1.6723e-01, -4.4777e-01, -3.2635e-02, 1.0710e-01, -5.2747e-03,
         -1.4691e-01, 8.1602e-02, -8.1311e-02, -3.8464e-01, -2.3607e-01,
         1.0437e-01, -1.0545e-01],
        [-7.7570e-02, -3.3674e-01, -1.0000e+04, -7.9387e-03, -3.6268e-02,
         -2.5619e-01, 1.9107e-01, -3.9694e-01, -2.0532e-01, 2.7869e-01,
         -4.8107e-01, 3.5782e-01, 5.9382e-02, 2.9848e-01, -3.5096e-01,
         -2.4258e-01, -6.5380e-02, 1.0745e-01, 1.8694e-01, -1.3979e-01,
         -3.1934e-01, -3.7313e-01, -3.4231e-02, 5.2480e-02, -2.4054e-02,
         -1.8017e-01, -5.7029e-02],
        [1.7202e-01, -1.2210e-01, -1.0000e+04, 1.5434e-01, -7.8892e-02,
         7.2557e-02, -4.5227e-01, 1.3346e-01, -9.5036e-02, -1.8690e-01,
         -3.7876e-01, -4.5667e-01, 5.9474e-02, -8.9215e-02, -3.5842e-01,
         -1.7302e-02, -3.0359e-01, -2.8202e-01, -1.9084e-01, 5.3924e-02,
         -1.6211e-01, -6.3177e-01, -1.3963e-01, -1.5983e-01, 1.5236e-02,
         -3.7506e-01, -3.5339e-01],
        [1.0319e-01, -8.0404e-02, -1.0000e+04, 5.5964e-02, -1.7229e-01,
         -1.1384e-01, 8.3113e-02, -1.5123e-01, -3.4868e-01, 1.5506e-01,
         -1.0288e-01, 4.7516e-02, 3.2357e-02, -4.9490e-01, -2.9977e-01,
         9.8116e-03, 1.3919e-01, -1.9543e-01, -5.7212e-02, -1.8231e-01,
         -3.4576e-01, -3.5837e-01, 4.4385e-02, 9.2445e-02, -7.9001e-02,
         -1.1538e-01, 1.1804e-01]]).detach().numpy()

    c2 = torch.Tensor([
        [2.0732e-01, 1.7930e+00, -1.0000e+04, -1.3231e+00, -1.1315e+00,
         1.0006e+00, -4.2231e-01, -1.5445e+00, -1.2393e+00, 1.7144e+00,
         -4.3535e-01, -1.1200e+00, -1.4344e+00, 1.5966e+00, 7.5732e-01,
         -1.4734e+00, -1.1415e+00, 9.0418e-01, -4.0229e-01, -4.7233e-01,
         -9.0874e-01, 7.1124e-01, -3.1328e-01, -1.7171e-01, -2.5815e-01,
         -1.3377e-01, -6.1548e-01],
        [-1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04, -1.0000e+04,
         -1.0000e+04, -1.0000e+04],
        [1.9913e+00, 2.1503e-01, -1.0000e+04, -1.6754e+00, -1.6213e+00,
         -1.1434e+00, -4.4441e-01, -1.1451e+00, -1.1245e+00, -1.5001e+00,
         -3.3897e-01, -1.2999e+00, -1.2798e+00, -1.2592e+00, -1.3607e+00,
         -1.3533e+00, -1.2220e+00, -1.2908e+00, -8.7305e-01, -1.1805e+00,
         -6.7091e-01, -8.8476e-01, -6.2799e-01, -7.1341e-01, -8.9370e-01,
         -3.2546e-01, -4.8364e-01],
        [1.6313e+00, -1.9037e+00, -1.0000e+04, -1.3546e+00, -1.1630e+00,
         -1.3919e+00, -5.0385e-01, -1.1431e+00, -9.2340e-01, -1.0827e+00,
         -4.2136e-01, -1.4006e+00, -1.2932e+00, -1.0636e+00, -1.3411e+00,
         -1.3675e+00, -1.3532e+00, -1.9277e+00, -4.4095e-01, -6.1779e-01,
         -4.6020e-01, -2.1880e-01, -3.4445e-01, -2.1138e-01, -6.2218e-01,
         -9.1990e-01, -3.8354e-01],
        [-1.6590e+00, -1.8247e+00, -1.0000e+04, 2.4447e+00, 4.2441e-01,
         -1.8310e+00, -6.8093e-01, -1.7237e+00, -1.2455e+00, -1.7137e+00,
         -6.8853e-01, -1.6385e+00, -5.7618e-01, -1.1892e+00, -1.4243e+00,
         -1.9034e+00, -1.4196e+00, -1.3809e+00, -7.5174e-01, -1.0052e+00,
         -9.7787e-01, -5.3487e-01, -6.2245e-01, -4.5099e-01, -5.8698e-01,
         -5.2496e-01, -4.8693e-01],
        [-6.7323e-01, -9.4464e-01, -1.0000e+04, 1.5333e-01, 2.7172e+00,
         -1.1955e+00, -5.8017e-01, -1.0972e+00, -1.1939e+00, -1.0675e+00,
         -3.5498e-01, -1.1419e+00, -1.1661e+00, -1.0996e+00, -1.1249e+00,
         -1.6150e+00, -9.7268e-01, -1.3576e+00, -4.4134e-01, -1.4425e-01,
         -8.5429e-01, -6.1037e-01, -7.0056e-01, -7.3718e-01, -5.0657e-01,
         -3.2826e-01, -6.2044e-01],
        [-6.5827e-02, -5.2783e-01, -1.0000e+04, -5.4822e-01, -3.2087e-01,
         -7.8593e-01, -7.0901e-01, -5.4324e-01, -5.8903e-01, -2.2290e-01,
         -5.0642e-01, -6.2455e-01, -6.3484e-01, -5.1258e-01, -5.2127e-01,
         -7.1918e-01, -5.6349e-01, -5.3061e-01, -6.6766e-01, -6.1502e-01,
         -2.7611e-01, -8.1206e-01, -6.9094e-01, -4.6518e-01, -5.0206e-01,
         -4.7426e-01, -6.9949e-01],
        [1.6657e+00, -1.7421e+00, -1.0000e+04, -9.9596e-01, -1.5828e+00,
         -1.1556e+00, -4.7059e-01, -1.3295e+00, -1.2731e+00, -1.6257e+00,
         -3.9523e-01, -1.3866e+00, -1.0282e+00, -1.3071e+00, -1.1144e+00,
         -1.0651e+00, -1.3870e+00, -1.5555e+00, -7.2723e-01, -5.1259e-01,
         -7.7253e-01, -5.6248e-01, -6.9159e-01, -6.4138e-01, -4.8038e-01,
         -5.5362e-01, -4.0071e-01],
        [-1.3013e+00, -1.3205e+00, -1.0000e+04, -1.3019e+00, -1.2038e+00,
         -1.4980e+00, -6.2955e-01, 1.9371e+00, 3.9517e-01, -1.1382e+00,
         -1.9702e-01, -1.7954e+00, -1.0643e+00, -1.0320e+00, -1.0835e+00,
         -1.1514e+00, -1.5297e+00, -1.6588e+00, -6.2217e-01, -6.1776e-01,
         -4.5741e-01, -4.1092e-01, -3.3913e-01, -4.2471e-01, -4.5715e-01,
         -8.0723e-01, -3.6780e-01],
        [-2.0712e+00, -1.1534e+00, -1.0000e+04, -1.4392e+00, -1.6362e+00,
         -1.6522e+00, -6.0692e-01, -1.5498e+00, 1.9378e+00, -1.5049e+00,
         -7.0093e-01, -1.6424e+00, -1.4580e+00, -6.6378e-01, -1.1933e+00,
         -1.4930e+00, -1.4502e+00, -1.6588e+00, -3.7335e-01, -7.2417e-01,
         -9.2024e-01, -5.8323e-01, -6.8831e-01, -5.8765e-01, -5.4638e-01,
         -4.3370e-01, -4.2564e-01],
        [-3.4221e-01, -9.9323e-01, -1.0000e+04, -3.2359e-01, -2.5708e-01,
         -5.2432e-01, -7.3642e-01, -9.2670e-01, -6.1122e-01, -4.9840e-01,
         -3.3971e-01, -3.7395e-01, -6.8259e-01, -8.1643e-01, -4.8042e-01,
         -4.3547e-01, -4.2263e-01, -5.9890e-01, -5.1298e-01, -9.3358e-01,
         -2.9323e-01, -5.3147e-01, -4.9593e-01, -3.8209e-01, -4.1197e-01,
         -6.1962e-01, -6.1349e-01],
        [1.4236e+00, -1.5572e+00, -1.0000e+04, -1.5183e+00, -1.1699e+00,
         -9.2933e-01, -4.5255e-01, -1.5057e+00, -1.0436e+00, -1.0447e+00,
         -5.1253e-01, -1.4509e+00, -1.9395e+00, -9.6326e-01, -1.6258e+00,
         -1.2959e+00, -1.0830e+00, -1.3540e+00, -7.4968e-01, -8.4499e-01,
         -7.5212e-01, -1.0166e+00, -6.4417e-01, -1.1129e+00, -1.0826e+00,
         -4.5549e-01, -4.5264e-01],
        [-1.5245e+00, -1.5278e+00, -1.0000e+04, -1.2996e+00, -6.7878e-01,
         -1.1358e+00, -4.1460e-01, -1.6336e+00, -1.1686e+00, -1.4557e+00,
         -5.6518e-01, 2.2471e+00, 4.4332e-01, -1.6571e+00, -1.1815e+00,
         -1.6196e+00, -1.3512e+00, -1.6726e+00, -3.5558e-01, -5.8110e-01,
         -1.0665e+00, -4.9995e-01, -4.6801e-01, -6.4543e-01, -8.2301e-01,
         -4.1322e-01, -4.2300e-01],
        [-1.5401e+00, -9.3083e-01, -1.0000e+04, -1.1575e+00, -1.3904e+00,
         -9.6087e-01, -6.9799e-01, -1.0016e+00, -1.0664e+00, -1.1053e+00,
         -7.0054e-01, 1.1215e+00, 1.7832e+00, -1.2379e+00, -1.2172e+00,
         -1.2368e+00, -8.8470e-01, -1.4437e+00, -5.5220e-01, -5.5296e-01,
         -5.5195e-01, -3.8045e-01, -6.7606e-01, -9.3271e-01, -5.1977e-01,
         -5.7555e-01, -7.2579e-01],
        [8.4245e-01, -1.5296e+00, -1.0000e+04, -1.2859e+00, -1.0690e+00,
         -1.1723e+00, -4.9932e-01, -1.4480e+00, -1.0315e+00, -1.2061e+00,
         -5.3488e-01, -1.2034e+00, -1.1295e+00, -8.7964e-01, -1.0226e+00,
         -1.1924e+00, -1.2419e+00, -1.3092e+00, -7.2367e-01, -9.2938e-01,
         -5.6800e-01, -5.6977e-01, -8.6174e-01, -3.7302e-01, -5.0019e-01,
         -3.8371e-01, -5.1366e-01],
        [1.0679e+00, -1.2479e+00, -1.0000e+04, -1.3817e+00, -1.4824e+00,
         -1.2017e+00, -5.9530e-01, -1.5090e+00, -9.8323e-01, -1.2787e+00,
         -4.4968e-01, -1.1680e+00, -1.2234e+00, -1.0235e+00, -1.4557e+00,
         -1.3013e+00, -1.1119e+00, -1.2350e+00, -8.3225e-01, -5.5986e-01,
         -1.0316e+00, -4.6995e-01, -7.1917e-01, -6.0788e-01, -5.0532e-01,
         -8.9628e-01, -4.4020e-01],
        [-7.1256e-01, -1.4808e+00, -1.0000e+04, -1.2516e+00, -1.1226e+00,
         -1.4255e+00, -7.6631e-01, -1.1773e+00, -1.1047e+00, -8.9584e-01,
         -3.1914e-01, -1.2166e+00, -8.8349e-01, -1.1225e+00, -1.1386e+00,
         2.2875e+00, 7.4876e-01, -1.6782e+00, -4.9381e-01, -9.7612e-01,
         -7.5617e-01, -1.6654e-01, -1.2267e-01, -4.9061e-01, -6.5970e-01,
         -8.4969e-01, -6.6829e-01],
        [-1.3495e+00, -1.8185e+00, -1.0000e+04, -1.3355e+00, -1.3249e+00,
         -1.3624e+00, -4.4661e-01, -1.5381e+00, -1.6301e+00, -1.4830e+00,
         -6.6912e-01, -1.3123e+00, -1.4019e+00, -1.4953e+00, -9.4057e-01,
         5.7538e-01, 2.0628e+00, -1.9417e+00, -5.7485e-01, -9.5596e-01,
         -1.2920e+00, -1.0077e+00, -5.0954e-01, -7.3302e-01, -6.9495e-01,
         -3.0206e-01, -6.6191e-01],
        [-2.9935e-01, -5.9240e-01, -1.0000e+04, -4.6698e-01, -7.5378e-01,
         -5.6869e-01, -5.2421e-01, -3.8258e-01, -4.5635e-01, -5.8538e-01,
         -3.9531e-01, -6.0011e-01, -5.8416e-01, -1.8005e-01, -7.1832e-01,
         -6.9233e-01, -1.9083e-01, -8.3304e-01, -6.4580e-01, -9.6443e-01,
         -4.4486e-01, -9.0628e-01, -4.8914e-01, -3.8452e-01, -9.4792e-01,
         -5.3187e-01, -3.8038e-01],
        [9.8730e-01, -1.0893e+00, -1.0000e+04, -2.4669e-01, -7.8015e-01,
         -5.5440e-01, -9.0971e-01, -7.2958e-01, -9.5706e-01, -8.7766e-01,
         -4.6713e-01, -3.6934e-01, -8.0330e-01, -4.8909e-01, -2.0931e-01,
         -8.4306e-01, -4.7716e-01, -1.1900e+00, -4.0797e-01, -5.7751e-01,
         -1.1075e+00, -5.4040e-01, -5.8856e-01, -6.1426e-01, -3.3426e-01,
         -5.4879e-01, -7.4202e-01],
        [-1.0914e+00, -6.2846e-01, -1.0000e+04, -9.7368e-01, -7.1560e-01,
         -4.4169e-01, -2.6990e-01, -1.0000e+00, -8.2026e-01, -1.0755e+00,
         -5.7486e-01, -7.6253e-01, -1.0555e+00, -5.8070e-02, -6.3425e-01,
         -1.0428e+00, -8.9582e-01, -9.5676e-01, -4.8470e-01, 1.1845e+00,
         7.1995e-01, -7.4738e-01, -2.3917e-01, -5.3026e-01, -6.4859e-01,
         -5.7386e-01, -5.0898e-01],
        [-6.3019e-01, -9.7132e-01, -1.0000e+04, -6.6107e-01, -8.5402e-01,
         -8.9870e-01, -5.6103e-01, -5.3574e-01, -5.7529e-01, -5.1608e-01,
         -6.7348e-01, -8.8758e-01, -4.8803e-01, -6.9401e-01, -4.0988e-01,
         -7.4107e-01, -5.8531e-01, -1.0832e+00, -9.9174e-01, -5.6618e-01,
         9.5406e-01, -6.5233e-01, -5.9797e-01, -8.2733e-01, -3.9448e-01,
         -6.3438e-01, -8.2341e-01],
        [-2.2595e-01, -5.8971e-01, -1.0000e+04, -3.6197e-01, -5.7717e-01,
         -4.7144e-01, -3.9038e-01, -7.1567e-01, -6.2497e-01, -6.3392e-01,
         -1.0335e+00, -4.8883e-01, -3.6026e-01, -7.7373e-01, -7.0005e-01,
         -6.4558e-01, -4.6746e-01, -6.9171e-01, -6.8739e-01, -8.2638e-01,
         -8.6433e-01, -5.3136e-01, -8.6489e-01, -4.3494e-01, -2.7872e-01,
         -7.7372e-01, -5.1223e-01],
        [-2.6978e-01, -3.6086e-01, -1.0000e+04, -5.6142e-01, -7.4142e-01,
         -7.6786e-01, -5.7364e-01, -5.8707e-01, -8.7250e-01, -6.6947e-01,
         -8.2756e-01, -5.2801e-01, -6.3173e-01, -7.1194e-01, -7.6602e-01,
         -2.9772e-01, -9.0921e-01, -5.2459e-01, -3.3719e-01, -4.2859e-01,
         -5.6360e-01, -3.7641e-01, -5.3424e-01, -8.2064e-01, -6.7095e-01,
         -3.5134e-01, -5.7555e-01],
        [-4.4402e-01, -8.4000e-01, -1.0000e+04, -4.8171e-01, -5.2407e-01,
         -7.1450e-01, -2.4982e-01, -8.7482e-01, -6.4513e-01, -1.7404e-01,
         -9.0869e-01, -1.2269e-01, -4.0796e-01, -1.3018e-01, -7.9773e-01,
         -7.0818e-01, -5.2389e-01, -3.7251e-01, -2.5735e-01, -5.6424e-01,
         -7.3814e-01, -8.2937e-01, -4.9060e-01, -3.8638e-01, -4.6069e-01,
         -6.3821e-01, -5.2753e-01],
        [-1.6867e-01, -5.9449e-01, -1.0000e+04, -3.2885e-01, -5.7007e-01,
         -3.8705e-01, -9.0399e-01, -3.5813e-01, -5.4364e-01, -6.4210e-01,
         -8.1889e-01, -9.4922e-01, -4.1948e-01, -5.2535e-01, -8.0857e-01,
         -4.9122e-01, -7.6687e-01, -7.6866e-01, -6.4961e-01, -3.8309e-01,
         -5.8611e-01, -1.1025e+00, -6.1670e-01, -6.1378e-01, -4.3761e-01,
         -8.4755e-01, -8.4124e-01],
        [-2.7235e-01, -5.8461e-01, -1.0000e+04, -4.5194e-01, -7.4788e-01,
         -5.9636e-01, -3.7332e-01, -6.5801e-01, -8.1476e-01, -3.2750e-01,
         -5.4882e-01, -4.6137e-01, -4.8009e-01, -9.4695e-01, -7.7567e-01,
         -4.9030e-01, -3.5763e-01, -7.0882e-01, -5.1769e-01, -6.2039e-01,
         -7.7590e-01, -8.3480e-01, -4.3459e-01, -3.6685e-01, -5.3377e-01,
         -5.9315e-01, -3.7255e-01]]).detach().numpy()

    print("debug")

    # 参考jieba里面的HMM去理解


if __name__ == '__main__':
    t2()
